package com.car.controller;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.car.entity.Carrentalorderform;
import com.car.page.Page;
import com.car.service.CarrentalorderformService;

@RestController
@RequestMapping("/trip")
public class TripController {
	
	@Autowired
	CarrentalorderformService carrentalorderformService;
	
	Map<String, Object> maps = new HashMap<>();
	private static final Logger logger = LoggerFactory.getLogger(VehicleMotioncarController.class);
	
	@RequestMapping("/show")
	public Map<String, Object> toShow(@RequestParam(value = "carId", required = false) Integer carId,
			@RequestParam(value = "start", required = false) Integer start,
 			@RequestParam(value = "pageIndex", required = false, defaultValue = "1") Integer pageNo,
			@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize){
		Page<Carrentalorderform> pages =carrentalorderformService.xingCheng(carId, start, pageNo, pageSize);
		if(pages.getList().isEmpty()){
			maps.put("msg", false);
		}else{
			maps.put("msg", true);
		}
		maps.put("page", pages);
		maps.put("list", pages.getList());
		maps.put("pageNo", pageNo);
		maps.put("start", start);
		return maps;
		
	}

}
